﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Helper;
using System.ComponentModel;
namespace CoreData
{
    public class Stock_VoucherIn
    {
        public long ID { get; set; }
        [Description("Số phiếu")]
        public string VoucherInNo { get; set; }
        [Description("Ngày lập phiếu")]
        public DateTime VoucherDate { get; set; }
        public long WarehouseID { get; set; }
        public long Input_MethodID { get; set; }
        [Description("Số chứng từ")]
        public string BillNo { get; set; }
        public long Payment_MethodID { get; set; }
        public long EmployeeID { get; set; }
        [Description("Ghi chú")]
        public string Note { get; set; }
        public long CreatedBy { get; set; }
        public DateTime CreatedDate { get; set; }
        public long LastModifiedBy { get; set; }
        public DateTime LastModifiedDate { get; set; }
        [Description("Thành tiền")]
        public decimal Amount { get; set; }
        [Description("Thuế VAT")]
        public bool VAT { get; set; }
        [Description("Tổng cộng")]
        public decimal TotalAmount { get; set; }
        public bool Active { get; set; }
        public bool IsDelete { get; set; }
        [Description("Kho")]
        public string StockNameExt { get; set; }
        [Description("Phương thức nhập")]
        public string Input_MethodNameExt { get; set; }
        [Description("Phương thức thanh toán")]
        public string PaymentMethodNameExt { get; set; }
        [Description("Người lập")]
        public string EmployeeNameExt { get; set; }

        public List<Stock_VoucherInDetail> VoucherInDetails;
        public Stock_VoucherIn()
        {
            VoucherInNo = "";
            BillNo = "";
            Note = "";
        }

        static Stock_VoucherIn DynamicCast<T>(object row_data, object row_header) where T : Stock_VoucherIn
        {
            // row_data : DataRow
            // row_header : DataColumnCollection
            Stock_VoucherIn ret = new Stock_VoucherIn();
            DataRow dt = (DataRow)row_data;

            foreach (DataColumn column in (DataColumnCollection)row_header)
            {
                switch (column.ColumnName)
                {
                    case "ID":
                        ret.ID = ConvertObject.ToInt(dt[column]);
                        break;
                    case "VoucherInNo":
                        ret.VoucherInNo = ConvertObject.ToString(dt[column]);
                        break;
                    case "VoucherDate":
                        ret.VoucherDate = ConvertObject.ToDateTime(dt[column]);
                        break;
                    case "WarehouseID":
                        ret.WarehouseID = ConvertObject.ToInt(dt[column]);
                        break;
                    case "Input_MethodID":
                        ret.Input_MethodID = ConvertObject.ToInt(dt[column]);
                        break;
                    case "BillNo":
                        ret.BillNo = ConvertObject.ToString(dt[column]);
                        break;
                    case "Payment_MethodID":
                        ret.Payment_MethodID = ConvertObject.ToInt(dt[column]);
                        break;
                    case "EmployeeID":
                        ret.EmployeeID = ConvertObject.ToInt(dt[column]);
                        break;
                    case "Note":
                        ret.Note = ConvertObject.ToString(dt[column]);
                        break;
                    case "Amount":
                        ret.Amount = ConvertObject.ToDecimal(dt[column]);
                        break;
                    case "VAT":
                        ret.VAT = ConvertObject.ToBool(dt[column]);
                        break;
                    case "TotalAmount":
                        ret.TotalAmount = ConvertObject.ToDecimal(dt[column]);
                        break;
                    case "Active":
                        ret.Active = ConvertObject.ToBool(dt[column]);
                        break;
                    case "IsDelete":
                        ret.IsDelete = ConvertObject.ToBool(dt[column]);
                        break;
                    case "CreatedBy":
                        ret.CreatedBy = ConvertObject.ToInt(dt[column]);
                        break;
                    case "CreatedDate":
                        ret.CreatedDate = ConvertObject.ToDateTime(dt[column]);
                        break;
                    case "LastModifiedBy":
                        ret.LastModifiedBy = ConvertObject.ToInt(dt[column]);
                        break;
                    case "StockName":
                        ret.StockNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "Input_MethodName":
                        ret.Input_MethodNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "PaymentMethodName":
                        ret.PaymentMethodNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    case "EmployeeName":
                        ret.EmployeeNameExt = ConvertObject.ToString(dt[column]);
                        break;
                    default:
                        break;
                }
            }

            return ret;
        }

    }
}
